package scala

import org.scalatest.FunSuite

class TestGCD extends FunSuite {

  import main.scala.AST._
  import main.scala.NativeFunctions.evidence
  
  test("addition single term") {
    assert(evidence(Add(List(Var("x")))) === Var("x"))
    assert(evidence(NumI(9)) === NumI(9))
  }
  
  test("sum Integer") {
    assert(evidence(Add(List(NumI(9), NumI(18)))) === NumI(9))
    assert(evidence(Add(List(NumI(9), NumI(18), NumI(6)))) === NumI(3))
  }
  
  test("sum Variable") {
    assert(evidence(Add(List(Var("x"), Var("x")))) === Var("x"))
    assert(evidence(Add(List(Var("x"), Var("x"), Var("x")))) === Var("x"))
  }
  
  test("Independent variables") {
    assert(evidence(Add(List(Var("x"), Var("y")))) === NumI(1))
    assert(evidence(Add(List(Var("x"), Var("y"), Var("x")))) === NumI(1))
    assert(evidence(Add(List(Var("x"), Var("x"), Var("y")))) === NumI(1))
  }
  
  test("multiply Integer") {
    assert(evidence(Mul(List(Var("x"), Var("y")))) === Mul(List(Var("x"), Var("y"))))
  }
}